from base.box import YamlHelper
from biz.ranzhi.main_page import MainPage


class ZonePage(MainPage):
    config_dict = YamlHelper().get_config_dict("biz/ranzhi.yaml")["ZonePage"]

    def click_zone_menu(self, menu):
        """
        我的地盘页面 点击菜单
        :param menu:
        :return:
        """

        self.driver.switch_to_frame(self.config_dict["FRAME_ZONE_SELECTOR"])

        # 调用父类的 click_menu
        super().click_menu(menu)
        self.driver.switch_to_default()

    def check_zone_menu_active_status(self, menu):
        """
        我的地盘，检查菜单是否处于激活状态
        :param menu:
        :return:
        """
        self.driver.switch_to_frame(self.config_dict["FRAME_ZONE_SELECTOR"])

        menu_selector = super()._get_menu_selector(menu)
        status = False
        if menu_selector is not None:
            menu_class_name = self.driver.get_attribute(menu_selector, "class")
            print(menu_class_name)
            status = "active" in menu_class_name

        self.driver.switch_to_default()
        return status
